﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Unipa.Framework.Data;
using System.Collections;
using DokuzEylul.Sinav.Entities;
using System.Collections.Generic;
using DokuzEylul.Sinav.Utility_Master;

namespace dokuzeylulworkshop.MasterUtilities
{
    public class dbmaster
    {
        private const string DB_ALIAS = "dokuzeylul";
        private static dbmaster sm_dbmaster;
        private static HybridDatabase m_dbprovider;
        /// <summary>
        /// boş constructur default tanımlı olan database i kullanır 
        /// </summary>
        public dbmaster()
        {
            m_dbprovider = DbFactory.CreateDatabase(DB_ALIAS);
        }
        /// <summary>
        /// bu constructor kullanılarak web config te tanımlanmış başka bir database e bağlanılavilir
        /// web configte yer alan database alias ını vermek yeterlidir
        /// </summary>
        /// <param name="dbAlias"></param>
        public dbmaster(string dbAlias)
        {
            m_dbprovider = DbFactory.CreateDatabase(dbAlias);
        }
        /// <summary>
        /// dbmaster sınıfına ait olan static instance
        /// </summary>
        public static dbmaster Instance
        {
            get
            {
                if (sm_dbmaster == null)
                    sm_dbmaster = new dbmaster();
                return sm_dbmaster;
            }
        }
        /// <summary>
        /// nhibernate e ait olan methodların gelmesini sağlar
        /// </summary>
        public HybridDatabase dbfactory
        {
            get
            {
                return m_dbprovider;
            }
        }

        #region intstances
        public MenuUtilities MenuInstance
        {
            get
            {
                return MenuUtilities.Instance;
            }
        }
        public UserUtilities UserInstance
        {
            get
            {
                return UserUtilities.Instance; 
            }
        }
        public DersKonuUtilities DersKonuInstance
        {
            get
            {
                return DersKonuUtilities.Instance;
            }
        }
        public SinavSoru SinavSoruInstance
        {
            get
            {
                return SinavSoru.Instance;
            }
        }
        #endregion

        #region AllDBMethod



        #endregion

    }
}
